/* eslint-disable eol-last */
/* eslint-disable indent */
/* eslint-disable strict */

'use strict';

module.exports = app => {
    // 引入数据类型
    const { INTEGER } = app.Sequelize;
    // 建模
    const UserRelation = app.model.define('UserRelation', {

        userId: {
            type: INTEGER,
            allowNull: false,
            comment: '粉丝的id',
        },
        followerId: {
            type: INTEGER,
            allowNull: false,
            comment: '被关注人的id',
        },
    });

    // 创建外键
    UserRelation.associate = () => {
        // 用户可以关注多个人
        app.model.UserRelation.belongsTo(app.model.User, {
            foreignKey: 'followerId',
        });
    };
    return UserRelation;
};